# 导入flask类
from flask import Flask, request,jsonify,make_response,Response
from werkzeug.routing import BaseConverter
from werkzeug.utils import secure_filename
import json

app = Flask(__name__)


@app.route("/")
def index():
    return f"<h1>参数传递</h1>"

@app.route("/response")
def response():
    # 响应体    状态码
    return 'Everything is OK', 404


@app.route("/response2")
def response2():
    # 响应体    状态码
    return 'Everything is OK', 404,{"xinlong":10}

@app.route('/error')
def error():
    response = Response('Custom response with headers', status=200)
    response.headers['X-Custom-Header'] = 'Value'
    return response



@app.route("/response3")
def response3():
    resp=make_response('make response 响应内容')
    resp.status='404 Not found'
    resp.headers['my_parm']='python-3.8'  #响应头
    return resp


@app.route('/api/data')
def api_data():
    data = {'key': 'value'}
    return jsonify(data)


if __name__ == '__main__':
    app.run(host='0.0.0.0', port=5000, debug=True)
